/**
 * @Company: 北京慧点科技有限公司 | www.smartdot.com.cn
 * @Copyright 1998-2020 © Smartdot Technologies Co., Ltd.
 */
package com.springlearn.zhoufei.other.spring.demo3;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

@Configurable // 相当于Bean2.xml
public class HelloEvent1_C {
    @Bean
    public HelloEvent1 HelloEvent1() {
        return new HelloEvent1();
    }
    @Bean
    public HelloEvent1_L1 HelloEvent1_L1() {
        return new HelloEvent1_L1();
    }
    @Bean
    public HelloEvent1_L2 HelloEvent1_L2() {
        return new HelloEvent1_L2();
    }
    public static void main(String[] args) {
        // 当实例化上下文时，不需要同时指定HelloWorld8_1.class和HelloWorld6_1.class，只有HelloWorld9类需要提供
        ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(HelloEvent1_C.class);
        // 上下文启动
        context.start();
        HelloEvent1 HelloEvent1 = context.getBean(HelloEvent1.class);
        System.out.println(HelloEvent1.toString());
        // 上下文停止
        context.stop();
    }
}